<?php

namespace App\Http\Controllers;

use App\Comment;
use foo\bar;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;

class CommentController extends Controller
{
    const DISPLAY_TYPE_NEST_ONE = 1;

    const DISPLAY_TYPE_NEST_MULTIPLE = 2;

    const DISPLAY_TYPE_HANG_ONE = 3;

    const DISPLAY_TYPE_HANG_MULTIPLE = 4;

    protected static $allDisplayTypes = [
        self::DISPLAY_TYPE_NEST_ONE => '嵌套一层',
        self::DISPLAY_TYPE_NEST_MULTIPLE => '嵌套多层',
        self::DISPLAY_TYPE_HANG_ONE => '悬挂一层',
        self::DISPLAY_TYPE_HANG_MULTIPLE => '悬挂多层',
    ];

    protected $defaultDisplayType = self::DISPLAY_TYPE_NEST_ONE;

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $displayTypeField = 'display_type';
        $displayType = $request->get($displayTypeField);
        if (!isset(self::$allDisplayTypes[$displayType])) {
            $displayType = $this->defaultDisplayType;
        }
        if (in_array($displayType, [self::DISPLAY_TYPE_NEST_ONE, self::DISPLAY_TYPE_NEST_MULTIPLE])) {
            $view = 'comment-nest';
        } else {
            $view = 'comment-hang';
        }
        return view($view, [
            'allDisplayType' => self::$allDisplayTypes,
            'displayType' => $displayType,
        ]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Comment  $comment
     * @return \Illuminate\Http\Response
     */
    public function show(Comment $comment)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Comment  $comment
     * @return \Illuminate\Http\Response
     */
    public function edit(Comment $comment)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Comment  $comment
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Comment $comment)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Comment  $comment
     * @return \Illuminate\Http\Response
     */
    public function destroy(Comment $comment)
    {
        //
    }

}
